package com.D5Power.Render
{
	import com.D5Power.Objects.BuildingObject;
	import com.D5Power.Objects.Effects.FeetStep;
	import com.D5Power.Objects.GameObject;
	import com.D5Power.Objects.IRender;
	
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	/**
	 * 用于处理只有一帧的物体
	 */ 
	public class RenderStatic extends Render
	{
		public function RenderStatic()
		{
			super();
		}
		
		override public function renderClear(o:GameObject):void
		{
			var m:IRender = o as IRender;
			
			
			if(m.isOver)
			{
				newpoint.x = o.Pos.x;
				newpoint.y = o.Pos.y;
			}else{
				newpoint = m.Scene.Map.getScreenPostion(o.Pos.x,o.Pos.y);
			}
			
			o.renderPoint.x = newpoint.x;
			o.renderPoint.y = newpoint.y;
			
			switch(o.renderPos)
			{
				case GameObject.CENTER:
					o.renderPoint.x-=o.graphics.frameWidth/2;
					o.renderPoint.y-=o.graphics.frameHeight/2;
					break;
				case GameObject.BOTTOM:
					o.renderPoint.x-=o.graphics.frameWidth/2;
					o.renderPoint.y-=o.graphics.frameHeight;
					break;
			}

			newpoint = o.renderPoint;
			lastpoint = o.lastRenderPoint;
			
			drawClear(o.graphics.bitmap,o.renderRect);
		}
		
		override public function render(o:GameObject):void
		{
			if(o.graphics==null) return;
			var m:IRender = o as IRender;

			//var target:Point = m.Scene.Map.getScreenPostion(o.Pos.x,o.Pos.y);
			
			newpoint=o.renderPoint;
			
			if(m.shadow!=null)
			{
				renderShadow(o,newpoint);
			}
			
			if(m.rendFly!=null)
			{
				newpoint.x+=m.rendFly.x;
				newpoint.y+=m.rendFly.y;
			}
			
			if(m.colorPan!=null)
			{
				o.graphics.bitmap.colorTransform(o.graphics.bitmap.rect,m.colorPan);
			}

			draw(o.graphics.bitmap,o.renderRect);
			
			o.lastRenderPoint.x = newpoint.x;
			o.lastRenderPoint.y = newpoint.y;
		}
	}
}